// 对上课提醒的一些操作
import axios from "axios";

// 取消上课提醒
export function deleteReminder(courseId) {
    return axios({
        method: "delete",
        url: "/api/courses/reminder",
        params: {
            courseId
        },
        header: {
            Authorization: localStorage.getItem("Authorization")
        }
    }).then(response => {
        return {
            result: true,
            data: response.data
        }
    }).catch(error => {
        return {
            result: true,
            msg: error.response.msg
        }
    })
}

// 获取我的上课提醒
export function getReminders() {
    return axios({
        method: "get",
        url: "/api/courses/reminder",
        header: {
            Authorization: localStorage.getItem("Authorization")
        }
    }).then(response => {
        return {
            result: true,
            data: response.data.result
        }
    }).catch(error => {
        return {
            result: false,
            msg: error.response.data.msg
        }
    })
}

// 添加上课提醒
export function addReminder(courseId) {
    return axios({
        method: "post",
        url: "/api/courses/reminder",
        data: {courseId: courseId},
        header: {
            Authorization: localStorage.getItem("Authorization")
        }
    }).then(response => {
        return {
            result: true,
            data: response.data
        }
    }).catch(error => {
        return {
            result: false,
            msg: error.response.data.msg
        }
    })
}
